package com.anonymous.util.test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

import com.anonymous.message.ChatMsg;
import com.anonymous.message.Message;
import com.anonymous.util.NetworkUtils;

public class SSLSend extends Thread {
	private Socket socket;
	private NetworkUtils networkUtils;
	
	public SSLSend(Socket socket){
		this.socket = socket;
		networkUtils = new NetworkUtils();
	}
	@Override
	public void run() {
		// TODO Auto-generated method stub
		super.run();
		BufferedReader inFromUser = new BufferedReader(
				new InputStreamReader(System.in));
		System.out.println("This is Client. Please type:\n");
		String sentence;
		Message result;
		while (true) {
			try {
				sentence = inFromUser.readLine();
				ChatMsg chatMsg = new ChatMsg();
				chatMsg.setFromUserName("Client");
				chatMsg.setMessage(sentence);
				networkUtils.send(chatMsg, socket);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}
	}

}
